//
//  GTFlutterMessageChannelImpl.swift
//  lib_core
//
//  Created by Shper on 2023/9/7.
//

import Foundation

class GTFlutterMessageChannelImpl: GTMessageChannelHostApi {
        
    static let shared: GTFlutterMessageChannelImpl = GTFlutterMessageChannelImpl()
    
    private init() {}
    
    func handleMessage(actionType: String, actionName: String, messageJson: String) throws {
        debugPrint("GTFlutter - handleMessage - actionType: \(actionType), actionName: \(actionName), messageJson: \(messageJson)")
        // 校验消息合法性
        if (actionType.isEmpty || actionName.isEmpty) {
            print("GTFlutter - The actionType or actionName is empty!")
            return
        }
        GTFlutterMessageCenter._dispatchMassage(actionType: actionType,
                                                       actionName: actionName,
                                                       messageJson: messageJson)
    }
    
}
